home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98a.txt
/
000016_icon-group-sender _Fri Jan 23 08:51:13 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id IAA13820
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Fri, 23 Jan 1998 08:51:12 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA02167; Fri, 23 Jan 1998 08:51:12 -0700
To: icon-group@optima.CS.Arizona.EDU
Date: Fri, 23 Jan 1998 10:36:44 +0100
From: Anders Holtsberg <andersh@maths.lth.se>
Message-Id: <34C864AC.3AA0@maths.lth.se>
Organization: Lund University
Sender: icon-group-request@optima.CS.Arizona.EDU
Subject: Interesting feature
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 1193
There is too little traffic here! Why? The perl and python
newsgroups are full and this ought to be too! In order to
improve the statistics we can discuss this little feature
I was bitten by when I wrote a program that built a complicated
tree.
procedure main()
# let's say that mytable is a node in a large tree
mytable := table([])
# and that the following is in a deep loop
put(mytable["A"], "B")
if not write(mytable["A"][1]) then write("FAIL 1")
if not write(mytable["C"][1]) then write("FAIL 2")
end
Now as an exercise try to guess what the program writes.
I tried to think of some more intuitive way Icon could have
behaved but I found none really.
The first solution I came up with was to insert the line
\mytable["A"] := []
before the the put-instruction. Then I came up with removing
the explicit list creation again by writing
mytable["A"] |||:= ["B"]
instead of the put-instruction. This seems astongishingly
enough to work as expected for nonexisting "A". Is this a
standard trick among you Icon gurus?
For long lists it may slow down things due to the extra
copying but my lists are short.
Comments? Improvements?
-- Anders Holtsberg